<div class="box">
    <div class="heading">
        <h1><img alt="" src="<?php echo base_url('assets/admin/images/setting.png'); ?>"> General Settings</h1>
        <div class="buttons">
            <a class="button" href="#" onClick="$('#settings_form').submit();"><span>Save</span></a>
        </div>
    </div>
    <div class="content">
        <?php echo form_open(null, 'id="settings_form"'); ?>
        <div class="tabs">
            <ul class="htabs">
                <li><a href="#general-tab">General</a></li>
				<li><a href="#follows-tab">Follows</a></li>
                <li><a href="#paymentgateway-tab">Payment Gateway</a></li>
            </ul>
            <!-- General Tab -->
            <div id="general-tab">
                <div class="form">
                    <div>
                        <?php echo form_label('<span class="required">*</span> Site Name:', 'sitename'); ?>
                        <?php echo form_input(array('name' => 'site_name', 'id' => 'sitename', 'value' => set_value('site_name',isset($settings['site_name']) ? $settings['site_name'] : ''))); ?>
                    </div>
					<div class="image">
						<div class="field_spacing">
							<?php echo form_label('<span class="required">*</span> Site logo:', 'sitelogo'); ?>
							<div class="attorneyimage">
								<img src="<?php echo base_url('assets/uploads/images').'/'.$settings['site_logo'] ;?>" alt="" id="thumb_logo" class="thumbimage" />
								<input type="hidden" name="site_logo" value="<?php echo isset($settings['site_logo']) ? $settings['site_logo'] : ''?>" id="site_logo" />
								<br />
								<a onclick="openKCFinder('site_logo','thumb_logo')">Browse</a>&nbsp;&nbsp;|&nbsp;&nbsp;<a onclick="$('#thumb_logo').attr('src', ''); $('#site_logo').attr('value', '');">Clear</a>
							</div>
						</div>
					</div>
					<div class="image">
						<div class="field_spacing">
							<?php echo form_label('<span class="required">*</span> Home Page Banner:', 'site_banner'); ?>
							<div class="attorneyimage">
								<img src="<?php echo base_url('assets/uploads/images').'/'.$settings['site_banner'] ;?>" alt="" id="thumb_banner" class="thumbimage" />
								<input type="hidden" name="site_banner" value="<?php echo isset($settings['site_banner']) ? $settings['site_banner'] : ''?>" id="site_banner" />
								<br />
								<a onclick="openKCFinder('site_banner','thumb_banner')">Browse</a>&nbsp;&nbsp;|&nbsp;&nbsp;<a onclick="$('#thumb_banner').attr('src', ''); $('#site_banner').attr('value', '');">Clear</a>
							</div>
						</div>
					</div>	
                    <div>
                        <?php echo form_label('<span class="required">*</span> Notification Email:', 'notification_email'); ?>
                        <?php echo form_input(array('name' => 'notification_email', 'id' => 'notification_email', 'value' => set_value('notification_email',isset($settings['notification_email']) ? $settings['notification_email'] : ''))); ?>
                    </div>
					<div>
                        <?php echo form_label('<span class="required">*</span> Countdown Datetime:', 'countdown_date'); ?>
                        <?php echo form_input(array('name' => 'countdown_date', 'id' => 'countdown_date', 'class'=>'datetimepicker', 'value' => set_value('countdown_date',isset($settings['countdown_date']) ? date("m/d/Y H:i",strtotime($settings['countdown_date'])) : ''))); ?>
                    </div>
					 <div>
                        <?php echo form_label('<span class="required">*</span> Site Homepage:', 'site_homepage'); ?>
							<select value="" name="site_homepage" id="site_homepage">
							<?php 
								foreach($pages as $page)
								{
									if($page['pageid']==$settings['site_homepage'])
									{
										echo "<option  value='".$page['pageid']."' selected='selected'>".$page['title']."</option>";
									}
									else
									{
										echo "<option  value='".$page['pageid']."'>".$page['title']."</option>";
									}
								}								
							?>
							</select>
                    </div>
				</div>
            </div>
			<!-- Follows Tab -->
            <div id="follows-tab">
                <div class="form">
                    <div>
                        <?php echo form_label('<span class="required"></span>:Facebook Link', 'Facebook_link'); ?>
                        <?php echo form_input(array('name' => 'facebook', 'id' => 'facebook', 'value' => set_value('facebook',isset($settings['facebook']) ? $settings['facebook'] : ''))); ?>
                    </div>
                    <div>
                        <?php echo form_label('<span class="required"></span>:Twitter Link', 'Twitter_link'); ?>
                        <?php echo form_input(array('name' => 'twitter', 'id' => 'twitter', 'value' => set_value('twitter',isset($settings['twitter']) ? $settings['twitter'] : ''))); ?>
                    </div>
					<div>
                        <?php echo form_label('<span class="required"></span>:Youtube Link', 'Youtube_link'); ?>
                        <?php echo form_input(array('name' => 'youtube', 'id' => 'youtube', 'value' => set_value('youtube',isset($settings['youtube']) ? $settings['youtube'] : ''))); ?>
                    </div>
                </div>
            </div>
			<!-- Payment Tab -->
            <div id="paymentgateway-tab">
				<ul class="vtabs">
					<li><a href="#Paypalstandard-tab">Paypal Standard</a></li>
					<!--<li><a href="#PayPalExpressCheckout-tab">PayPal Express Checkout</a></li>
					<li><a href="#PayPalWebsitePaymentsPro-tab">PayPal Website Payments Pro</a></li>
					<li><a href="#2Checkout-tab">2Checkout</a></li>
					<li><a href="#AuthorizeNetAIM-tab">Authorize.Net AIM</a></li>-->
					
				</ul>
				<div class="paymentgateway" id="Paypalstandard-tab">
					<?php 
					$paypal=json_decode($settings['paypal']);
					//print_r($paypal);
					
					?>
					<div class="form">
						<div>
							<?php echo form_label('<span class="required"></span>:Paypal Email', 'paypal_email'); ?>
							<?php echo form_input(array('name' => 'paypal_email', 'id' => 'paypal_email', 'value' => set_value('paypal_email',isset($paypal->paypal_email) ? $paypal->paypal_email : ''))); ?>
						</div>
						<div>
							<?php echo form_label('<span class="required"></span>:Sandbox Mode', 'sandbox_mode'); ?>
							<input type="radio" name="sandbox_mode" value="yes" <?php if($paypal->sandbox_mode=='yes') echo 'checked="checked"'; ?> />Yes
							<input type="radio" name="sandbox_mode" value="no" <?php if($paypal->sandbox_mode=='no') echo 'checked="checked"'; ?> />No
						</div>
						<div>
							<?php echo form_label('<span class="required">*</span> Status:', 'status'); ?>
							<?php echo form_dropdown('status', array('enable'=>'enable','disabled' => 'Disabled' ,), set_value('status',!empty($paypal->status) ? $paypal->status : ''), 'id=\'status\'')?>
						</div>
					</div>
				</div>
				
				<!--<div class="paymentgateway" id="PayPalExpressCheckout-tab">
					<div class="form">
						<div>
							<?php echo form_label('<span class="required"></span>:API Username', 'paypal_api_username'); ?>
							<?php echo form_input(array('name' => 'paypal_api_username', 'id' => 'paypal_api_username', 'value' => set_value('paypal_email',isset($settings['paypal_email']) ? $settings['paypal_email'] : ''))); ?>
						</div>
						<div>
							<?php echo form_label('<span class="required"></span>:API Password', 'paypal_api_password'); ?>
							<?php echo form_input(array('name' => 'paypal_api_password', 'id' => 'paypal_api_password', 'value' => set_value('paypal_email',isset($settings['paypal_email']) ? $settings['paypal_email'] : ''))); ?>
						</div>
						<div>
							<?php echo form_label('<span class="required"></span>:API Signature', 'paypal_api_signature'); ?>
							<?php echo form_input(array('name' => 'paypal_api_signature', 'id' => 'paypal_api_signature', 'value' => set_value('paypal_email',isset($settings['paypal_email']) ? $settings['paypal_email'] : ''))); ?>
						</div>
						<div>
							<?php echo form_label('<span class="required"></span>:Sandbox Mode', 'sandbox_mode'); ?>
							<input type="radio" name="sandbox_mode" value="yes" <?php if($settings['sandbox_mode']=='yes') echo 'checked="checked"'; ?> />Yes
							<input type="radio" name="sandbox_mode" value="no" <?php if($settings['sandbox_mode']=='no') echo 'checked="checked"'; ?> />No
						</div>
						<div>
							<?php echo form_label('<span class="required">*</span> Status:', 'status'); ?>
							<?php echo form_dropdown('status', array('enable'=>'enable','disabled' => 'Disabled' ,), set_value('status',''), 'id=\'status\'')?>
						</div>
					</div>
				</div>
				<div class="paymentgateway" id="PayPalWebsitePaymentsPro-tab">
					<div class="form">
						<div>
							<?php echo form_label('<span class="required"></span>:API Username', 'paypal_api_username'); ?>
							<?php echo form_input(array('name' => 'paypal_api_username', 'id' => 'paypal_api_username', 'value' => set_value('paypal_email',isset($settings['paypal_email']) ? $settings['paypal_email'] : ''))); ?>
						</div>
						<div>
							<?php echo form_label('<span class="required"></span>:API Password', 'paypal_api_password'); ?>
							<?php echo form_input(array('name' => 'paypal_api_password', 'id' => 'paypal_api_password', 'value' => set_value('paypal_email',isset($settings['paypal_email']) ? $settings['paypal_email'] : ''))); ?>
						</div>
						<div>
							<?php echo form_label('<span class="required"></span>:API Signature', 'paypal_api_signature'); ?>
							<?php echo form_input(array('name' => 'paypal_api_signature', 'id' => 'paypal_api_signature', 'value' => set_value('paypal_email',isset($settings['paypal_email']) ? $settings['paypal_email'] : ''))); ?>
						</div>
						<div>
							<?php echo form_label('<span class="required"></span>:Sandbox Mode', 'sandbox_mode'); ?>
							<input type="radio" name="sandbox_mode" value="yes" <?php if($settings['sandbox_mode']=='yes') echo 'checked="checked"'; ?> />Yes
							<input type="radio" name="sandbox_mode" value="no" <?php if($settings['sandbox_mode']=='no') echo 'checked="checked"'; ?> />No
						</div>
						<div>
							<?php echo form_label('<span class="required">*</span> Status:', 'status'); ?>
							<?php echo form_dropdown('status', array('enable'=>'enable','disabled' => 'Disabled' ,), set_value('status',''), 'id=\'status\'')?>
						</div>
					</div>
				</div>
				<div class="paymentgateway" id="2Checkout-tab">
					<div class="form">
						<div>
							<?php echo form_label('<span class="required"></span>:Account Id', 'account_id'); ?>
							<?php echo form_input(array('name' => 'account_id', 'id' => 'account_id', 'value' => set_value('account_id',isset($settings['paypal_email']) ? $settings['paypal_email'] : ''))); ?>
						</div>
						<div>
							<?php echo form_label('<span class="required"></span>:Secret Word', 'secret_word'); ?>
							<?php echo form_input(array('name' => 'secret_word', 'id' => 'secret_word', 'value' => set_value('secret_word',isset($settings['paypal_email']) ? $settings['paypal_email'] : ''))); ?>
						</div>
						<div>
							<?php echo form_label('<span class="required"></span>:Sandbox Mode', 'sandbox_mode'); ?>
							<input type="radio" name="sandbox_mode" value="yes" <?php if($settings['sandbox_mode']=='yes') echo 'checked="checked"'; ?> />Yes
							<input type="radio" name="sandbox_mode" value="no" <?php if($settings['sandbox_mode']=='no') echo 'checked="checked"'; ?> />No
						</div>
						<div>
							<?php echo form_label('<span class="required">*</span> Status:', 'status'); ?>
							<?php echo form_dropdown('status', array('enable'=>'enable','disabled' => 'Disabled' ,), set_value('status',''), 'id=\'status\'')?>
						</div>
					</div>
				</div>
				<div class="paymentgateway" id="AuthorizeNetAIM-tab">
					<div class="form">
						<div>
							<?php echo form_label('<span class="required"></span>:Api Login Id', 'api_login_id'); ?>
							<?php echo form_input(array('name' => 'api_login_id', 'id' => 'api_login_id', 'value' => set_value('api_login_id',isset($settings['api_login_id']) ? $settings['api_login_id'] : ''))); ?>
						</div>
						<div>
							<?php echo form_label('<span class="required"></span>:Transaction Key', 'transaction_key'); ?>
							<?php echo form_input(array('name' => 'transaction_key', 'id' => 'transaction_key', 'value' => set_value('transaction_key',isset($settings['api_login_id']) ? $settings['api_login_id'] : ''))); ?>
						</div>
						<div>
							<?php echo form_label('<span class="required"></span>:Sandbox Mode', 'sandbox_mode'); ?>
							<input type="radio" name="sandbox_mode" value="yes" <?php if($settings['sandbox_mode']=='yes') echo 'checked="checked"'; ?> />Yes
							<input type="radio" name="sandbox_mode" value="no" <?php if($settings['sandbox_mode']=='no') echo 'checked="checked"'; ?> />No
						</div>
						<div>
							<?php echo form_label('<span class="required">*</span> Status:', 'status'); ?>
							<?php echo form_dropdown('status', array('enable'=>'enable','disabled' => 'Disabled' ,), set_value('status',''), 'id=\'status\'')?>
						</div>
					</div>
				</div>	-->
            </div>
        </div>
        <?php echo form_close(); ?>
    </div>
</div>
<style type="text/css">
.thumbimage {
    height: 100px;
    overflow: hidden;
    cursor: pointer;
    background: #000;
    color: #fff;
}
</style>
<script type="text/javascript">
function openKCFinder(field, thumb) {
    window.KCFinder = {
        callBack: function(url) {
            window.KCFinder = null;
            var img = new Image();
            img.src = url;
            img.onload = function() {
				$('#' + thumb).attr('src',url);
				var lastSlash = url.lastIndexOf("images/");
				var fileName=url.substring(lastSlash+7);
				/*var fileName = url.split('/').pop().split('\\').pop();
				alert (field);*/
				$('#' + field).attr('value',fileName);
            }
        }
    };
    window.open('<?php echo base_url();?>assets/admin/js/kcfinder/browse.php?type=images&dir=images',
        'kcfinder_image', 'status=0, toolbar=0, location=0, menubar=0, ' +
        'directories=0, resizable=1, scrollbars=0, width=800, height=600'
    );
}
</script>
<script type="text/javascript">
    $(document).ready(function() {
        $( ".tabs" ).tabs();
		$("#paymentgateway-tab").tabs();
    });
</script>